<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>12 vue的数据类型操作</title>
    <script src="./js/vue.js"></script>
</head>
<body>
    <div id="app">
        <h3>{{str}}</h3>
        <h3>用户名<input :id = "str" :value = "str" :style = "css" @input = "change">
            <span>{{tips}}</span>
        </h3>
        <button @click="fanzhuang">反转</button>
    </div>
    
</body>

<script>
    new Vue({
        el:"#app",
        data:{
            num : 100,
            str : "我是字符串",
            css : "color:red",
            tips : ""
        },
        methods:{
            change(){
                this.str = window.event.target.value;

                if(this.str.length >= 3 && this.str.length <= 9){
                    this.tips = "√";
                }else{
                    this.tips = "用户名是3——9";
                }
            },
            fanzhuang(){
                this.str = this.str.split("").reverse().join("")
            }
        }
    })


</script>
</html>